/*
 *
 * author：dustin
 * email:dushaobindoudou@gmail.com
 * version: 0.0.01
 * 
 * 
 */
(function(win){
    var doc = win.document;
    var isString = function(obj){
        return Object.prototype.toString.call(obj) === "[object String]";
    }
    var bind = function(ele, event, handler){
        if (ele.addEventListener) {
            ele.addEventListener(event, handler, false);
        }
        else 
            if (ele.attachEvent) {
                ele.attachEvent("on" + event, handler);
            }
            else {
                ele["on" + event] = handler;
            }
    }
    var unbind = function(){
        if (ele.removeEventListener) {
            ele.removeEventListener(event, handler, false);
        }
        else 
            if (ele.detachEvent) {
                ele.detachEvent("on" + event, handler);
            }
            else {
                //只能removeAttribute了
                ele["on" + event] = "";
            }
    }
    var cloneEle = function(ele, deep){
        return ele.cloneNode(deep);
        
    }
    var setAtt = function(ele, attr, val){
        if (ele.setAttribute) {
            ele.setAttribute(attr, val)
        }
        ele[attr] = val;
    }
    var getAttr = function(ele, attr){
        if (ele.getAttribute) {
            return ele.getAttribute(attr)
        }
        return ele[attr];
        
    }
    var removeAttr = function(ele, attr){
        if (ele, removeAttribute) {
            ele.removeAttribute(attr)
        }
        ele[attr] = "";
        delete ele[attr];
    }
    var style = function(ele, name, value){
        if (!value) {
            if (name == "opacity") {
                if ("opacity" in ele.style) {
                
                }
                else {
                    var matches = reg.alpher.match(ele.style["filter"]);
                    if (matches) {
                        return matches[1];
                    }
                    return 0;
                }
            }
            
            return ele.style[name];
        }
        else {
            if (name == "opacity") {
                if ("opacity" in ele.style) {
                
                }
                else {
                    ele.style["filter"] = "alpha(opacity = " + value * 100 + ")";
                    ele.style["zoom"] = 1;
                }
            }
            ele.style[name] = value;
        }
    }
    var eleSize = function(ele){
        var winW = 0, winH = 0;
        if (ele == self) {
            if (document.body && document.body.offsetWidth) {
                winW = document.body.offsetWidth;
                winH = document.body.offsetHeight;
            }
            if (document.compatMode == 'CSS1Compat' &&
            document.documentElement &&
            document.documentElement.offsetWidth) {
                winW = document.documentElement.offsetWidth;
                winH = document.documentElement.offsetHeight;
            }
            if (window.innerWidth && window.innerHeight) {
                winW = window.innerWidth;
                winH = window.innerHeight;
            }
            return {
                width: winW,
                height: winH
            }
        }
        else {
            return {
                width: ele.offsetWidth,
                height: ele.offsetHeight
            }
        }
    }
    var hasClass = function(ele, cls){
        return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
    }
    
    var addClass = function(ele, cls){
        if (!hasClass(ele, cls)) {
            ele.className += " " + cls;
        }
    }
    var removeClass = function(ele, cls){
        if (hasClass(ele, cls)) {
            var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
            ele.className = ele.className.replace(reg, ' ');
        }
    }
    var replaceClass = function(ele, oldClass, newClass){
        if (hasClass(ele, oldClass)) {
            removeClass(ele, oldClass);
            addClass(ele, newClass);
        }
        return;
    }
	var eleIsChild = function(){
		
		
	}
	// findPos() by quirksmode.org
	// Finds the absolute position of an element on a page
	var findPos = function(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {	
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;	
			} while (obj = obj.offsetParent);
		}
		return [curleft,curtop];
	};
 
	// getPageScroll() by quirksmode.org
	// Finds the scroll position of a page
	var getPageScroll = function() {
		var xScroll, yScroll;
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
			xScroll = self.pageXOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {
			yScroll = document.documentElement.scrollTop;
			xScroll = document.documentElement.scrollLeft;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
			xScroll = document.body.scrollLeft;
		}
		return [xScroll,yScroll]
	};
 
	// Finds the position of an element relative to the viewport.
	var findPosRelativeToViewport = function(obj) {
		var objPos = findPos(obj)
		var scroll = getPageScroll()
		return [ objPos[0]-scroll[0], objPos[1]-scroll[1] ]
	}
 
    
    var Slider = function(currentMonthId, headMonthId, evtHand){
		var prevHand = evtHand.previous;//绑定向前 处理默认值
		var nextHand = evtHand.next;//绑定向后 处理默认值
		
        this.currentMonEle = isString(currentMonthId) ? doc.getElementById(currentMonthId) : currentMonthId;
        this.headMonthEle = isString(headMonthId) ? doc.getElementById(headMonthId) : headMonthId;
		
		this.prevHand = isString(prevHand)? doc.getElementById(prevHand) : prevHand;
		this.nextHand = isString(nextHand)? doc.getElementById(nextHand) : nextHand;
		
		this.theSelectedDay = null;
        //this.nextMonthId = isString(nextMonthId) ? doc.getElementById(nextMonthId) : nextMonthId;
        this.timer = new Timer();
		this.timerMon = new Timer();
		
		//给Frame分配一个命名空间
		this.frameNS = {};
		//给弹出框一个名字空间
		this.popupBoxNS = {};
		
        this.init();
    }
    var lang = {
        zh: {
            month: ["十二月", "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月"]
        }
    }
    Slider.prototype = {
        constructor: Slider,
        nextMonth: function(){
            var that = this;
            //var currentMonList = that.currentMonEle.children[0]; //得到当前月的日期列表
            
            var next = null;
            //获取当前 日期			   
            var currMon = that.getCurrentMonth();
            next = new Date(currMon.year, currMon.month);
            next.setMonth(next.getMonth() + 1);
            var pl = that.generMonth(next);
            that.currentMonEle.appendChild(pl);
			//设置当前月
			that.setCurrentMonth(next.getFullYear(),(next.getMonth() + 1));
            //setAtt(that.currentMonEle, "currentMon", next.getFullYear() + "-" + (next.getMonth() + 1));

        },
        generMonth: function(currentMonth){
            var that = this;
            var pl = doc.createElement("div");//创建文档
            var nm = doc.createElement("div");
            var curM = doc.createElement("div");
            var nmcnt = doc.createElement("span");
            var curMon = doc.createElement("span");
            var nextMonth = null;
            addClass(nm, "calFootDateCntNext");
            //生成上一月            
            addClass(curM, "currentMonth");
            curMon.innerHTML = lang.zh.month[(currentMonth.getMonth() + 1) % 12];
            curM.appendChild(curMon);
            //生成下一月            
            addClass(nmcnt, "NextMonth");
            nmcnt.innerHTML = lang.zh.month[(currentMonth.getMonth() + 2) % 12];
            nm.appendChild(nmcnt);
            //生成当前月的日期
            nextMonth = that.createNextMonth(currentMonth.getFullYear(), currentMonth.getMonth());
            //附加到pl上
            pl.appendChild(curM);
            pl.appendChild(nextMonth);
            pl.appendChild(nm);
            addClass(pl, "datePannel");
            return pl;
        },
        prevMonth: function(){
            var that = this;
            var currentMonList = that.currentMonEle.children[0]; //得到当前月的日期列表            
            var next = null;
            //获取日期
            currMon = that.getCurrentMonth();
            next = new Date(currMon.year, currMon.month);
            next.setMonth(next.getMonth() - 1);
            var pl = that.generMonth(next);
            that.currentMonEle.style.left = -626 + "px";
            that.currentMonEle.insertBefore(pl, currentMonList);
			//设置当前月
			that.setCurrentMonth(next.getFullYear(),next.getMonth() + 1);
		
            //setAtt(that.currentMonEle, "currentMon", next.getFullYear() + "-" + (next.getMonth() + 1));
        },
        moveToLeft: function(callback){
            var that = this;
			//移动日历内容
            var left = that.currentMonEle.style.left;
			var hm = that.headMonthEle.children[0];
            var leftHead = hm.style.left;
            that.currentMonEle.style.left = ((parseInt(left) ? parseInt(left) : 0) - 10) + "px";
			
			var hmV = (eleSize(this.headMonthEle.children[0].children[0]).width)/(eleSize(this.currentMonEle.children[0]).width - 44)*10;
			//移动标题月份
			var fLeftHead = parseFloat(leftHead);
            hm.style.left = (isNaN(fLeftHead)?0:fLeftHead - hmV) + "px";
			//要保证速度一致
        	
            callback.call(that, that.currentMonEle.style.left,hm.style.left);
            return;
        },
        startToLeft: function(){
            this.nextMonth();
			this.createNextMonthHand();
            var theDayWidth = (eleSize(this.currentMonEle.children[0]).width - 44);
			var theHeadWidth = (eleSize(this.headMonthEle.children[0].children[0]).width);
			var oneToTheEnd = false;
            this.timer.init(this.moveToLeft, 10, this);
            this.timer.runTimer(function(dayLeft,monthLeft){
                var dayLeft = parseInt(dayLeft);
				var headLeft = parseInt(monthLeft);
				//判断是否移动到指定位置了 日期内容
                if (Math.abs(dayLeft || 0) >= theDayWidth - 10) {
					oneToTheEnd = true;
                }
				//判断头月份是否移动到指定位置了
				if(Math.abs(headLeft || 0) >= theHeadWidth - 1){
					oneToTheEnd = true;
				}
				
				if(oneToTheEnd){
					
					//重置月份头位置
					this.headMonthEle.children[0].style.left = -theHeadWidth +"px";
					this.resetCalendarHeadMonth(0);					
					
					//重置日期位置
                    this.currentMonEle.style.left = -(theDayWidth + 44) + "px";
                    this.resetCalendarDate(0);
                    //console.log("sop");
					//停止计时器
                    this.timer.stopTimer();
					
					//重置end标示
					oneToTheEnd = false;
				}
				
            });
        },
        moveToRight: function(callback){
            var that = this;
            var left = that.currentMonEle.style.left;
           

			var hm = that.headMonthEle.children[0];
            var leftHead = hm.style.left;
            that.currentMonEle.style.left = ((parseInt(left) ? parseInt(left) : 0) + 10) + "px";
			
			var hmV = (eleSize(this.headMonthEle.children[0].children[0]).width)/(eleSize(this.currentMonEle.children[0]).width - 44)*10;
			//移动标题月份
			var fLeftHead = parseFloat(leftHead);
            hm.style.left = (isNaN(fLeftHead)?0:fLeftHead + hmV) + "px";
			//that.currentMonEle.style.left = ((parseInt(left) ? parseInt(left) : 0) + 10) + "px";
			
            callback.call(that, that.currentMonEle.style.left,hm.style.left);
            return;
        },
        startToRight: function(){
            this.prevMonth();
			this.createPreviousMonthHand();
            var theWidth = (eleSize(this.currentMonEle.children[0]).width - 34);
			var theHandWidth = (eleSize(this.headMonthEle.children[0].children[0]).width);
			var isToTheEnd = false;
            this.timer.init(this.moveToRight, 10, this);
            this.timer.runTimer(function(left,headLeft){
                var left = parseInt(left);
                if ((left || 0) >= - 10) {
					isToTheEnd = true;
                }
				if((headLeft || 0) >=-1 ){
					isToTheEnd = true;
				}
				
				if(isToTheEnd){
					//重置日期
					this.currentMonEle.style.left = -(theWidth + 34) + "px";
                    this.resetCalendarDate(1);
                    //console.log("sop");
					// 重置月份头
					this.headMonthEle.children[0].style.left = 0;
					this.resetCalendarHeadMonth(1);
					//停止timer
                    this.timer.stopTimer();
				}
				
            });
        },
        resetCalendarDate: function(idx){
            var that = this;
            var theTemp = null,len = 0;
			//that.currentMonEle.children[idx];
			//todo：　性能有点低 不过速度是最快的 没有发现更好的方法
			if(!idx){//remove all element before last elment
				//得到不用删除的元素的引用，保证内存不会释放掉
				len = that.currentMonEle.children.length;
				theTemp = that.currentMonEle.children[len - 1].cloneNode(true);
				//clear all element
				that.currentMonEle.innerHTML = "";
				that.currentMonEle.appendChild(theTemp);
				
			}else{//remove all element after the first element
				//得到不要删除的元素的引用，保证不会从内存中删除
				theTemp = that.currentMonEle.children[0].cloneNode(true);
				that.currentMonEle.innerHTML = "";
				that.currentMonEle.appendChild(theTemp);
				
			}
			//设置选中项
			that.findCurrentSelectedDay();
            
			//that.currentMonEle.removeChild(theFirstChild);
			//初始化元素当前的位置
            that.currentMonEle.style.left = "0";            
        }, 
		resetCalendarHeadMonth:function(idx){
			var that = this;
			var hm= that.headMonthEle.children[0];
			var theTemp = null, len = 0;
			//delete all element
			
			if(!idx){//remove all element before last element
				len = hm.children.length;
				//todo:可以用选择lastElement 原始方法 兼容性 没有测试 暂时用  children len - 1 是否可以在元素片段修改 减少也没重绘
				// ie 下面有问题，他会直接 清除掉所有node
				theTemp = hm.children[len - 1].cloneNode(true);
				hm.innerHTML = "";
				hm.appendChild(theTemp);
			}else{
				theTemp = hm.children[0].cloneNode(true);
				hm.innerHTML = "";
				hm.appendChild(theTemp);
			}
           	// var theFirstChild = hm.children[idx];
			//这里要清除 除了今天以外的所有内容
            //hm.removeChild(theFirstChild);
			//设置初始化样式
            hm.style.left = "0";
		},
		createNextMonthHand:function(){//插入下一月并移动
			var that = this;
			var currMon = that.getCurrentMonth();
			var nextMon = doc.createElement("span");
			var hm = that.headMonthEle.children[0];
			next = new Date(currMon.year, currMon.month);
            next.setMonth(next.getMonth());
			nextMon.innerHTML = lang.zh.month[(next.getMonth()) % 12 ];
			hm.appendChild(nextMon);
		},
		createPreviousMonthHand:function(){
			var that = this;
			var currMon = that.getCurrentMonth();
			var nextMon = doc.createElement("span");
			var hm = that.headMonthEle.children[0];
			next = new Date(currMon.year, currMon.month);
            next.setMonth(next.getMonth());
			nextMon.innerHTML = lang.zh.month[(next.getMonth()) % 12 ];
			
			hm.insertBefore(nextMon,hm.children[0]);
			style(hm,"left","-44px")
		},
        init: function(){
        	//初始化的时候要设置当前是 哪一年 哪一月  每次要用的时候都要重新获取一面出问题
        	var that = this;
			that.bindHandler();
			//附加日期
			that.setCurrentDay();
			
			that.findCurrentSelectedDay();
			
			//that.createNewFrame();
			
        },
		getCurrentMonth:function(){
			var that = this;
			var currMon = getAttr(that.currentMonEle, "currentMon");//得到现在是哪一月        
            currMon = currMon.split("-");
			return {
				year:currMon[0],
				month:currMon[1] - 1
			}
		},
		setCurrentMonth:function(year,month){
			var that = this;
			setAtt(that.currentMonEle, "currentMon", year + "-" + month);
		},	
        createNextMonth: function(year, month){
            var cal = new Calendar();
            var strMon = "", ul = doc.createElement("ul"), div = doc.createElement("div");
            addClass(ul, "dateContainer");
            addClass(div, "DateList")
            cal.init("not process", function(count, year, month, day, week){
                //处理今天
                strMon += '<li data-detailday="'+year+"-"+month+"-"+day+'-'+week+'" class="today selectedDay"><span>' + day + '</span></li>';
            }, function(count, year, month, day, week){
                //普通天数
                // console.log(year + "-" + month + "-" + day + ":星期" + week);
                strMon += '<li data-detailDay="'+year+"-"+month+"-"+day+'-'+week+'"><span>' + day + '</span></li>';
                
            }).generateDate(year, month, 1);
            
            ul.innerHTML = strMon;
            div.appendChild(ul);
            return div;
        },bindHandler:function(){
			var that = this;			
			// 设置后一个月
			bind(that.currentMonEle,"mousedown",function(){
				var target = arguments[0].srcElement || arguments[0].target;
				
				//that.aniDay(target);
				if(target.nodeName == "SPAN" && hasClass(target,"NextMonth")){
					that.startToLeft();
					return;
				}
				if(hasClass(target.parentNode,"calFootDateCntNext")){
					that.startToLeft();
					return;
				}
				//设置选中项
				if(target.nodeName == "SPAN" && target.parentNode.nodeName == "LI" && getAttr(target.parentNode,"data-detailday")){
					
					that.changeSelectedDay(target.parentNode);
					win.TARGET_TEST = target.parentNode;
					that.popupBox(target.parentNode);
					return;
				}
				if(target.nodeName == "LI" && getAttr(target,"data-detailday")){
					that.changeSelectedDay(target);
					win.TARGET_TEST = target;
					that.popupBox(target);
					return;
				}
				
				
			});
			//清除弹出层
			bind(that.currentMonEle,"mouseup",function(){
				var target = arguments[0].srcElement || arguments[0].target;
				//设置选中项
				if(target.nodeName == "SPAN" && target.parentNode.nodeName == "LI" && getAttr(target.parentNode,"data-detailday")){
										
					that.clearPopupBox();
					return;
				}
				if(target.nodeName == "LI" && getAttr(target,"data-detailday")){
					
					that.clearPopupBox();
					return;
				}				
			});

			
			//设置前一个月
			bind(that.headMonthEle,"click",function(evt){
				that.startToRight();
				return;
			});
			
			//绑定下一天
			bind(that.prevHand,"click",function(){
				that.previousDay();
				return;
			});
			
			//绑定上一天
			bind(that.nextHand,"click",function(){
				that.nextDay();
				return;
			})
			
		},
		popupBox:function(target){
			var that = this;
			if(!target){
				return;
			}
			that.clearPopupBox();
			var cnt = getAttr(target,"data-detailday");
			var pop =  that.createPopupBox();
			var tarPos = findPos(target);
			style(pop,"display","block");
			var popWidth = that.popupBoxNS.popupBox.offsetWidth;
			var popHeight = that.popupBoxNS.popupBox.offsetHeight;
			var tarWidth = target.offsetWidth;			
			var thePos = (tarPos[0] + parseFloat(tarWidth)/2) - parseFloat(popWidth)/2;
			style(pop,"top", (tarPos[1] - 85) + "px");
			style(pop,"left",(thePos) + "px");
			//console.log(thePos);
			that.setPopupBoxText(cnt);
			//执行缓动
			that.setTween(pop,{height:popHeight,width:popWidth},{top:tarPos[1] - 85,left:thePos});
		},
		clearPopupBox:function(){
			var pup = this.popupBoxNS.popupBox;
			if(pup){
				pup.parentNode.removeChild(pup);
			}
			this.popupBoxNS.popupBox = null;
			
		},
		setCurrentDay:function(){
			var that = this;
			var now = new Date();
			var currentYear = now.getFullYear();
			var currentMonth = now.getMonth() + 1;
			var currentDay = now.getDate();
			var pl = null;
			//设置当前日期
			setAtt(that.currentMonEle,"currentMon",currentYear+"-"+currentMonth+"-" + currentDay);
			//生成当前日期
			pl = that.generMonth(now);
			that.currentMonEle.appendChild(pl);
			
		},findCurrentSelectedDay:function(){
			var that = this;
			var selected = that.currentMonEle.querySelector("li.selectedDay");
			if(selected){
				that.theSelectedDay = selected;
			}else{
				//设置一个默认的
				that.theSelectedDay = that.currentMonEle.querySelector(".dateContainer").firstElementChild;
				addClass(that.theSelectedDay,"selectedDay");
			}
			
		},changeSelectedDay:function(target){
			var that = this;
			if (target != that.theSelectedDay) {
				//addClass(target, "selectedDay");
				that.frameNS.target = target;
				removeClass(that.theSelectedDay, "selectedDay");
				//removeAttr(that.theSelectedDay,)
				that.aniDay(that.theSelectedDay,target);
				that.theSelectedDay = target;
			}
		},aniDay:function(from,to){
			var that = this;
			var frame;
			if(!from && !to && from == to){
				return;
			}
			var fromPos = findPos(from);
			var toPos = findPos(to);
			//Todo:这个强耦合需要修正
			fromPos[1] = fromPos[1] - 2;
			that.removeCurrentFrame();
			frame = that.frameNS.divFrame = that.createNewFrame();			
			that.frameNS.distanceX = toPos[0] - fromPos[0];		
			that.frameNS.distanceY = 0;	
			//that.frameNS.toPos = toPos;				
			style(frame,"display","block");
			style(frame,"top", (fromPos[1])+"px");
			style(frame,"left", fromPos[0]+"px");
			//style(frame,"background","#000000");
			style(frame,"display","block");			
			//that.removeCurrentFrame();
			that.timerMon.init(that.moveTheFrame,10,that);
			that.timerMon.runTimer(function(leftVal,speed){
				if(Math.abs(toPos[0] - leftVal) < Math.abs(speed)){
					this.removeCurrentFrame();
					addClass(that.frameNS.target, "selectedDay");
					this.timerMon.stopTimer();
				} 
			});
		},
		removeCurrentFrame:function(){
			var div = this.frameNS.divFrame;
			if (div) {
				div.parentNode.removeChild(div);
				this.frameNS.divFrame = null;
			}
			
		},
		moveTheFrame:function(callback){
			var that = this;
			var left = style(that.frameNS.divFrame,"left");
			var top  = style(that.frameNS.divFrame,"top");
			var speedX = that.frameNS.distanceX/20;
			var speedY = that.frameNS.distanceY/20;
			leftVal = parseFloat(left) + speedX;
			topVal = parseFloat(top) + speedY;			
			style(that.frameNS.divFrame,"left",leftVal+"px");
			style(that.frameNS.divFrame,"top",topVal+"px");
			callback.call(that,leftVal,speedX,speedY);
			
		},
		createNewFrame:function(){
			var div = doc.createElement("div");
			addClass(div,"virtualSelectedDay");
			doc.body.appendChild(div);
			//style(div,"display","block");
			//style(div,"background","#333333")
			return div;
		},
		nextDay:function(){
			var that = this;
			var currentSelectedDay = that.theSelectedDay;
			//todo:这个会出问题
			var nxDy = currentSelectedDay.nextElementSibling || currentSelectedDay.nextSibling;
			if(nxDy){
				that.changeSelectedDay(nxDy);				
			}else{				
				that.startToLeft();
			}
			
		},
		previousDay:function(){
			var that = this;
			var currentSelectedDay = that.theSelectedDay;
			var pyDy = currentSelectedDay.previousElementSibling || currentSelectedDay.previousSibling;
			if(pyDy){
				that.changeSelectedDay(pyDy);				
			}else{				
				that.startToRight();
			}			
		},
		createPopupBox:function(){
			var divPan = doc.createElement("div");
			addClass(divPan,"popupBox");
			var cnt = '<div class="content-background"><div class="popupBoxText"></div></div><div class="arrow-down-border"><div class="arrow-down"></div></div>';
			divPan.innerHTML = cnt;
			style(divPan,"display","none");
			style(divPan,"position","absolute");
			style(divPan,"zIndex","9999");
			doc.body.appendChild(divPan);
			this.popupBoxNS.popupBox = divPan;
			return divPan;
		},getPopupBoxText:function(){
			var cnt;
			if(this.popupBoxNS.popupBox){
				cnt = this.popupBoxNS.popupBox.querySelector(".popupBoxText");
				if(cnt){
					return cnt.innerHTML;
				}
			}
			
		},setPopupBoxText:function(val){
			if(!val){
				return ;
			}
			var i=0;
			var det = val.replace(/-/g,function($1){
				i++;
				switch(i){
					case 1:
					return "年";
					break
					case 2:
					return "月";
					break;
					case 3:
					return "日";
					break;
					default:
					return "-";
				}
				
			});
			if(this.popupBoxNS.popupBox){
				cnt = this.popupBoxNS.popupBox.querySelector(".popupBoxText");
				if(cnt){
					cnt.innerHTML = det;
				}
			}
		},setTween:function(target,size,pos,offset){
			var that = this;
			if(!Tween || !target){
				return;
			}
			var h =  offset || 60;
			var v = size.height/size.width*20;
			var twHeight = new Tween(target.style,"height",Tween.elasticEaseOut,(size.height - v),size.height,1,"px");
			var twLeft = new Tween(target.style,"left",Tween.elasticEaseOut,(pos.left - h/2),pos.left,1,"px");
			var twWidth = new Tween(target.style,"width",Tween.elasticEaseOut,(size.width + h),size.width,1,"px");
			var twTop = new Tween(target.style,"top",Tween.elasticEaseOut,(pos.top + v/2),pos.top,1,"px");
			//并行执行
			var pl = new Parallel();
			pl.addChild(twHeight);
			pl.addChild(twLeft);
			pl.addChild(twWidth);
			pl.addChild(twTop);
			
			pl.start();
		}
        
    }
    win.Slider = Slider;
    
}).call(this, this)
